/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network.version;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author rbs
 */
public class VersionInfo {
    
    private int version[] = new int[3];

    public int getValue()
    {
        return version[0]*100 + version[1]*10 + version[2];
    }
    
    public VersionInfo()
    {
        BufferedReader file;
        try {
            file = new BufferedReader(new FileReader("set/ver"));
            new VersionInfo(file.readLine());
        } catch (Exception ex) {
            Logger.getLogger(VersionInfo.class.getName()).log(Level.SEVERE, null, ex);
            new VersionInfo("0.0.0");
        }
        
    }
    
    public VersionInfo(String input) {

        String splitted[] = input.split("\\.");

        for(int i = 0; i < 3; i++)
            version[i] = Integer.parseInt(splitted[i]);
    }

    public String getString()
    {
        return version[0] + "." + version[1] + "." + version[2];
    }

    public static boolean isNewer(VersionInfo ver1, VersionInfo ver2)
    {
        return ver1.getValue() < ver2.getValue();
    }
}